#include "Game.h"
// globals
#include "Defines.h"
#include "Renderer.h"
#include "Structs.h"
#include "Triangle.h"
#include "Box.h"
#include "Circle.h"
#include "Timmer.h"

//--------------------------------------------------------------------------------
Game::Game(HINSTANCE hInstance)
:m_pkWindows(NULL),m_hInstance(hInstance)
{

}
//--------------------------------------------------------------------------------
Game::~Game()
{

}
//--------------------------------------------------------------------------------
bool Game::StartUp()
{
	//variable temporal para almacenar el hWnd recibirlo del createWindow y 

	HWND hWnd=NULL;
	// creo un objeto windows
	m_pkWindows = new Window(m_hInstance);

	if (!m_pkWindows)
		return false;
	// creo la ventana
	m_pkWindows->createWindow(800, 600, hWnd);
	render = new Renderer(hWnd);
	timer.FristMeasure();


	if (!OnStartUp())
		return false;

	return true;
}
//--------------------------------------------------------------------------------
bool Game::Loop()
{
	
	Circle tr(15);
	tr.setPos(0,0,1);
	tr.setDim(100, 100);
	tr.setRotation(0);
	tr.draw(render);
	render->setViewportPosition(0,0);
	tr.Update(0);


	if (OnLoop()){
		return true;
	}
	
	stringstream s;
	unsigned int fps =  timer.GetFPS();
	s << "Engine v0.1 - FPS: " << fps;
//	m_pkWindows->SetWindowTitle(strcat("Engine v0.1 - FPS",itoa(fps))); 
	m_pkWindows->SetWindowTitle(s.str().c_str()); 
	timer.Measure();
	return false;
}
//--------------------------------------------------------------------------------
bool Game::ShutDown()
{
	if (!OnShutDown())
		return false;

	if (m_pkWindows)
		delete m_pkWindows;

	m_pkWindows = NULL;

	


	return true;
}
//--------------------------------------------------------------------------------
